package td0.shape;

public class Rectangle extends Shape2D {

	private double length;
	private double width;

	public Rectangle(int length, int width) {
		super("Rectangle");
		this.length = length;
		this.width = width;
	}

	@Override
	public double perimeter() {
		return length * 2d + width * 2d;
	}

	@Override
	public double surface() {
		return length * width;
	}

	public double diagonal() {
		return Math.sqrt(length * length + width * width);
	}

	@Override
	public String toString() {
		return getName() + " [length=" + length + ", width=" + width + "]";
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null)
			return false;

		if (obj == this)
			return true;

		if (!this.getClass().equals(obj.getClass()))
			return false;

		Rectangle r = (Rectangle) obj;
		return r.width == this.width && r.length == this.length;
	}

	public double getLength() {
		return length;
	}

	public void setLength(double length) {
		this.length = length;
	}

	public double getWidth() {
		return width;
	}

	public void setWidth(double width) {
		this.width = width;
	}
}
